import time
from functools import wraps


def cal_run_time(cal_func_place: str):
    """
    计算运行时间

    :param cal_func_place:
    :return:
    """

    def decorator(func):
        @wraps(func)
        def wrapper():
            start = time.time()
            result = func()
            end = time.time()
            time_m = end - start
            print("{} 耗时 {}".format(cal_func_place, time_m))
            return result

        return wrapper

    return decorator


@cal_run_time(cal_func_place="test")
def func_test():
    time.sleep(1)
    return "test result"


if __name__ == '__main__':
    r = func_test()
    print(r)
